<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>jenkins自动部署版本回滚 | Alexcld</title><meta name="keywords" content="jenkins自动部署版本回滚"><meta name="author" content="Alex"><meta name="copyright" content="Alex"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="系统版本 ubuntu 20.4 LTS WSL    tomcat版本 apache-tomcat-8.5.30   jenkins.war版本 2.313   java 1.8.0   maven 3.6.3   安装java,maven环境，我这里使用ubuntumaven使用apt安装的，jdk使用源码装的 安装jdk1tar -zxvf jdk-8u221-linux-x64.ta">
<meta property="og:type" content="article">
<meta property="og:title" content="jenkins自动部署版本回滚">
<meta property="og:url" content="http://blogtest.alexcld.com/posts/5876.html">
<meta property="og:site_name" content="Alexcld">
<meta property="og:description" content="系统版本 ubuntu 20.4 LTS WSL    tomcat版本 apache-tomcat-8.5.30   jenkins.war版本 2.313   java 1.8.0   maven 3.6.3   安装java,maven环境，我这里使用ubuntumaven使用apt安装的，jdk使用源码装的 安装jdk1tar -zxvf jdk-8u221-linux-x64.ta">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://img.alexcld.com/img/170734-15694024544d72.jpg">
<meta property="article:published_time" content="2021-10-09T08:07:14.000Z">
<meta property="article:modified_time" content="2021-10-09T08:08:10.857Z">
<meta property="article:author" content="Alex">
<meta property="article:tag" content="jenkins自动部署版本回滚">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://img.alexcld.com/img/170734-15694024544d72.jpg"><link rel="shortcut icon" href="https://img.alexcld.com/img/author.png"><link rel="canonical" href="http://blogtest.alexcld.com/posts/5876"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//fonts.googleapis.com" crossorigin=""/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?ed29f24d552b68e914260fcff2860767";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium+Web&amp;display=swap" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"bottom-left"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'jenkins自动部署版本回滚',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-10-09 16:08:10'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          const now = new Date()
          const hour = now.getHours()
          const isNight = hour <= 6 || hour >= 18
          if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
          else if (t === 'light') activateLightMode()
          else activateDarkMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.2.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://img.alexcld.com/img/author.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">29</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">29</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">11</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/download"><i class="fa-fw fa fa-download"></i><span> 下载</span></a></div><div class="menus_item"><a class="site-page" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 追剧怪</span></a></div><div class="menus_item"><a class="site-page" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 博主</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://img.alexcld.com/img/170734-15694024544d72.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Alexcld</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/download"><i class="fa-fw fa fa-download"></i><span> 下载</span></a></div><div class="menus_item"><a class="site-page" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 追剧怪</span></a></div><div class="menus_item"><a class="site-page" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 博主</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">jenkins自动部署版本回滚</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-10-09T08:07:14.000Z" title="发表于 2021-10-09 16:07:14">2021-10-09</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-10-09T08:08:10.857Z" title="更新于 2021-10-09 16:08:10">2021-10-09</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">2k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>9分钟</span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><table>
<thead>
<tr>
<th>系统版本</th>
<th>ubuntu 20.4 LTS WSL</th>
</tr>
</thead>
<tbody><tr>
<td>tomcat版本</td>
<td>apache-tomcat-8.5.30</td>
</tr>
<tr>
<td>jenkins.war版本</td>
<td>2.313</td>
</tr>
<tr>
<td>java</td>
<td>1.8.0</td>
</tr>
<tr>
<td>maven</td>
<td>3.6.3</td>
</tr>
</tbody></table>
<h1 id="安装java-maven环境，我这里使用ubuntu"><a href="#安装java-maven环境，我这里使用ubuntu" class="headerlink" title="安装java,maven环境，我这里使用ubuntu"></a>安装java,maven环境，我这里使用ubuntu</h1><p>maven使用apt安装的，jdk使用源码装的</p>
<h2 id="安装jdk"><a href="#安装jdk" class="headerlink" title="安装jdk"></a>安装jdk</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar -zxvf jdk-8u221-linux-x64.tar.gz -C &#x2F;usr&#x2F;local&#x2F; 				#解压jdk至&#x2F;usr&#x2F;local</span><br></pre></td></tr></table></figure>
<p>在/etc/profile文件文件底部添加如下内容,保存退出并source /etc/profile使改动生效</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">export JAVA_HOME&#x3D;&#x2F;usr&#x2F;local&#x2F;jdk1.8.0_221</span><br><span class="line">export JRE_HOME&#x3D;$&#123;JAVA_HOME&#125;&#x2F;jre</span><br><span class="line">export CLASSPATH&#x3D;.:$&#123;JAVA_HOME&#125;&#x2F;lib:$&#123;JRE_HOME&#125;&#x2F;lib:$CLASSPATH</span><br><span class="line">export JAVA_PATH&#x3D;$&#123;JAVA_HOME&#125;&#x2F;bin:$&#123;JRE_HOME&#125;&#x2F;bin</span><br><span class="line">export PATH&#x3D;$PATH:$&#123;JAVA_PATH&#125;</span><br></pre></td></tr></table></figure>
<h2 id="安装maven"><a href="#安装maven" class="headerlink" title="安装maven"></a>安装maven</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo apt update</span><br><span class="line">sudo apt install maven #安装maven,默认安装路径为&#x2F;usr&#x2F;share&#x2F;maven</span><br></pre></td></tr></table></figure>
<p>在/etc/profile文件文件底部添加如下内容,保存退出并source /etc/profile使改动生效</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">export M2_HOME&#x3D;&#x2F;usr&#x2F;share&#x2F;maven</span><br><span class="line">export MAVEN_HOME&#x3D;&#x2F;usr&#x2F;share&#x2F;maven</span><br><span class="line">export PATH&#x3D;$&#123;M2_HOME&#125;&#x2F;bin:$&#123;PATH&#125;</span><br></pre></td></tr></table></figure>
<h1 id="安装tomcat-jenkins"><a href="#安装tomcat-jenkins" class="headerlink" title="安装tomcat,jenkins"></a>安装tomcat,jenkins</h1><p>首先解压tomcat</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar -zxvf apache-tomcat-8.5.30.tar.gz -C &#x2F;usr&#x2F;local&#x2F; &amp;&amp; mv &#x2F;usr&#x2F;local&#x2F;apache-tomcat-8.5.30 &#x2F;usr&#x2F;local&#x2F;tomcat</span><br></pre></td></tr></table></figure>
<p>然后把下载好的jenkins.war移动至 webapps，因为tomcat支持直接以jar,war包的形式来启动项目，所以启动tomcat也就是启动jenkins</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mv &#x2F;soft&#x2F;jenkins.war &#x2F;usr&#x2F;local&#x2F;tomcat&#x2F;webapps&#x2F;</span><br></pre></td></tr></table></figure>
<p>启动jenkins</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">bash &#x2F;usr&#x2F;local&#x2F;tomcat&#x2F;bin&#x2F;startup.sh</span><br></pre></td></tr></table></figure>
<p>访问<a target="_blank" rel="noopener" href="http://172.25.1.74:8080/jenkins%EF%BC%8C%E6%8C%89%E7%85%A7%E6%8F%90%E7%A4%BA%E5%AE%8C%E6%88%90%E5%AE%89%E8%A3%85%E5%8D%B3%E5%8F%AF">http://172.25.1.74:8080/jenkins，按照提示完成安装即可</a></p>
<h1 id="创建project进行构建"><a href="#创建project进行构建" class="headerlink" title="创建project进行构建"></a>创建project进行构建</h1><p>新建test，选择构建一个自由风格的软件项目，然后点击确定<br><img src="https://img-blog.csdnimg.cn/71cb3dfad1854f5fbd51d62767746432.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"><br>然后选择参数化构建过程，分别添加选项参数，字符参数<br><img src="https://img-blog.csdnimg.cn/d6e3a5f355164c9588a843fd8e9a6426.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"><br>然后选择源码管理，填自己的仓库<br><img src="https://img-blog.csdnimg.cn/6c366eec27fc40db8e4323ad787e667d.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16"></p>
<p>构建环境 选择Delete workspace before build starts<br><img src="https://img-blog.csdnimg.cn/86df85b7a3374ab9b43adf9bfe828bec.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"><br>然后在构建步骤里新加一个shell，我红框圈住的地方已经做了注释，正常情况是可以启动java程序的，但是写在这里发现部署成功后，没有java的程序，日志也是为空。所以最后在主机上写了个shell来代替。<br><img src="https://img-blog.csdnimg.cn/c489140c33fc4e13bd3552233b1269be.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line">#!&#x2F;bin&#x2F;bash</span><br><span class="line">cd $&#123;WORKSPACE&#125;&#x2F; &amp;&amp; mvn install</span><br><span class="line">cd $&#123;WORKSPACE&#125;&#x2F;group-module &amp;&amp;  mvn clean package -Dmaven.test.skip&#x3D;true</span><br><span class="line"></span><br><span class="line">case $Status  in</span><br><span class="line">  Deploy)</span><br><span class="line">    echo &quot;Status:$Status&quot;</span><br><span class="line">    path&#x3D;&quot;&#x2F;opt&#x2F;bak&#x2F;$&#123;BUILD_NUMBER&#125;&quot;      #创建每次要备份的目录</span><br><span class="line">    if [ -d $path ];</span><br><span class="line">    then</span><br><span class="line">        echo &quot;The files is already  exists &quot;</span><br><span class="line">    else</span><br><span class="line">        mkdir -p  $path</span><br><span class="line">    fi</span><br><span class="line">    #APP_NAME&#x3D;group-module-1.0-SNAPSHOT.jar</span><br><span class="line">    #pid&#x3D;&#96;ps -ef|grep $APP_NAME|grep -v grep|awk &#39;&#123;print $2&#125;&#39; &#96;</span><br><span class="line">	#if [ -n &quot;$&#123;pid&#125;&quot; ]; then</span><br><span class="line">	#kill -9 $pid</span><br><span class="line">	#fi</span><br><span class="line">    \cp -f $&#123;WORKSPACE&#125;&#x2F;group-module&#x2F;target&#x2F;group-module-1.0-SNAPSHOT.jar $path &amp;&amp; cp -f $&#123;WORKSPACE&#125;&#x2F;group-module&#x2F;target&#x2F;group-module-1.0-SNAPSHOT.jar &#x2F;opt&#x2F;group-module&#x2F;  #将打包好的war包备份到相应目录,覆盖已存在的目标</span><br><span class="line">    #nohup java -jar &#x2F;opt&#x2F;group-module&#x2F;group-module-1.0-SNAPSHOT.jar &gt; &#x2F;opt&#x2F;group-module&#x2F;group-module-1.0-SNAPSHOT.log 2&gt;&amp;1 &amp;      </span><br><span class="line">    echo &quot;Completing!&quot;</span><br><span class="line">    ;;</span><br><span class="line">  Rollback)</span><br><span class="line">      echo &quot;Status:$Status&quot;</span><br><span class="line">      echo &quot;Version:$Version&quot;</span><br><span class="line">      cd &#x2F;opt&#x2F;bak&#x2F;$Version #进入备份目录</span><br><span class="line">      #APP_NAME&#x3D;group-module-1.0-SNAPSHOT.jar</span><br><span class="line">      #pid&#x3D;&#96;ps -ef|grep $APP_NAME|grep -v grep|awk &#39;&#123;print $2&#125;&#39; &#96;</span><br><span class="line">	  #if [ -n &quot;$&#123;pid&#125;&quot; ]; then</span><br><span class="line">	  #kill -9 $pid</span><br><span class="line">	  #fi</span><br><span class="line">      \cp -f group-module-1.0-SNAPSHOT.jar &#x2F;opt&#x2F;group-module&#x2F; #将备份拷贝到程序打包目录中，并覆盖之前的jar包</span><br><span class="line">      #nohup java -jar &#x2F;opt&#x2F;group-module&#x2F;group-module-1.0-SNAPSHOT.jar &gt; &#x2F;opt&#x2F;group-module&#x2F;group-module-1.0-SNAPSHOT.log 2&gt;&amp;1 &amp;       </span><br><span class="line">      ;;</span><br><span class="line">  *)</span><br><span class="line">  exit</span><br><span class="line">      ;;</span><br><span class="line">esac</span><br></pre></td></tr></table></figure>
<p>由于我们经常更新代码，提交构建，使得备份目录日益变大，所以需要写一个脚本来删除老旧的版本，将版本控制在5个，再构建的地方新增一个shell<br><img src="https://img-blog.csdnimg.cn/86bcb31c605c4601aeee8eb15afa003f.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">#!&#x2F;bin&#x2F;bash</span><br><span class="line">ReservedNum&#x3D;5  #保留文件数</span><br><span class="line">FileDir&#x3D;&#x2F;opt&#x2F;bak&#x2F;</span><br><span class="line">date&#x3D;$(date &quot;+%Y%m%d-%H%M%S&quot;)</span><br><span class="line"></span><br><span class="line">cd $FileDir   #进入备份目录</span><br><span class="line">FileNum&#x3D;$(ls -l | grep &#39;^d&#39; | wc -l)   #当前有几个文件夹，即几个备份</span><br><span class="line"></span><br><span class="line">while(( $FileNum &gt; $ReservedNum))</span><br><span class="line">do</span><br><span class="line">    OldFile&#x3D;$(ls -rt | head -1)         #获取最旧的那个备份文件夹</span><br><span class="line">    echo  $date &quot;Delete File:&quot;$OldFile</span><br><span class="line">    rm -rf $FileDir&#x2F;$OldFile</span><br><span class="line">    let &quot;FileNum--&quot;</span><br><span class="line">done </span><br></pre></td></tr></table></figure>
<p>最后把我上边说的部署服务的脚本写在服务器上<br>新增shell<br><img src="https://img-blog.csdnimg.cn/7523566f2b1c44019b0f8a0dccd428eb.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"><br>服务器脚本内容<br><img src="https://img-blog.csdnimg.cn/bcdd55e99c92409b858f6eafef5b9165.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">APP_NAME&#x3D;group-module-1.0-SNAPSHOT.jar</span><br><span class="line"></span><br><span class="line">pid&#x3D;&#96;ps -ef|grep $APP_NAME|grep -v grep|awk &#39;&#123;print $2&#125;&#39; &#96;</span><br><span class="line">if [ -n &quot;$&#123;pid&#125;&quot; ]; then</span><br><span class="line">kill -9 $pid</span><br><span class="line">fi</span><br><span class="line">BUILD_ID&#x3D;DONTKILLME</span><br><span class="line">nohup java -jar &#x2F;opt&#x2F;group-module&#x2F;group-module-1.0-SNAPSHOT.jar &gt; &#x2F;opt&#x2F;group-module&#x2F;group-module-1.0-SNAPSHOT.log 2&gt;&amp;1 &amp;</span><br></pre></td></tr></table></figure>
<h1 id="验证"><a href="#验证" class="headerlink" title="验证"></a>验证</h1><h2 id="Deploy"><a href="#Deploy" class="headerlink" title="Deploy"></a>Deploy</h2><p>目前并没有进程<br><img src="https://img-blog.csdnimg.cn/f7fc3e661a234e5d9caed5bb46d069a4.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"><br>我们打开jenkins控制台，依次选择我们的部署方式，以及版本号，然后点击开始构建<br><img src="https://img-blog.csdnimg.cn/f18dfc5d24c94fbda7c09fdf17d3eec1.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"><br>查看控制台输出，这里已经部署成功，也可以看到状态时Deploy<br><img src="https://img-blog.csdnimg.cn/fd7568da8b654cf9b0df56130bbd8308.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"><br>到服务器上查看，进程已经起来了，日志显示启动成功<br><img src="https://img-blog.csdnimg.cn/5bd22f44a3ed462aa7843e3ac381b51a.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"><br>可以看下此次部署已备份至我们指定的目录，没有22的原因是，我当时构建22的时候回滚的是21<br><img src="https://img-blog.csdnimg.cn/7035da9d6a0a41fda3649641d8f71158.png" alt="在这里插入图片描述"></p>
<h2 id="Rollback"><a href="#Rollback" class="headerlink" title="Rollback"></a>Rollback</h2><p>我们再来到控制台，依次选择之后点击构建<br><img src="https://img-blog.csdnimg.cn/b12fae6baa2a4fe28e308796dc9c839c.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16"><br>看控制台我们，可以看出部署的方式，及回滚的版本<br><img src="https://img-blog.csdnimg.cn/503aea992a3b4d3487d0169135eb97a0.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"><br>再来到服务器查看，发现进程号已经变了，说明回滚成功<br><img src="https://img-blog.csdnimg.cn/2177bbdbdf644ee7b8e950b7ccb64c8b.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"></p>
<h1 id="以上写的是后端，这里再补发一个前端的"><a href="#以上写的是后端，这里再补发一个前端的" class="headerlink" title="以上写的是后端，这里再补发一个前端的"></a>以上写的是后端，这里再补发一个前端的</h1><h2 id="安装node"><a href="#安装node" class="headerlink" title="安装node"></a>安装node</h2><p>这里尽量使用源码来安装与你项目匹配的node版本，否则可能出现依赖问题，或者版本问题，这里我简化安装</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">apt update</span><br><span class="line">apt install nodejs npm</span><br></pre></td></tr></table></figure>
<h2 id="新建前端项目"><a href="#新建前端项目" class="headerlink" title="新建前端项目"></a>新建前端项目</h2><p>这里我们直接copy之前后端的配置，然后再进行改动<img src="https://img-blog.csdnimg.cn/f6454d5d2291484a875f17fbdc9093ea.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"><br>源码管理改成自己前端的仓库地址<br><img src="https://img-blog.csdnimg.cn/3d7fa1b8189d4ab49cd13118d2c7d71c.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"><br>我绿色框住的内容需要按照你自己的路径来改动<img src="https://img-blog.csdnimg.cn/19761ad746f74b0eb78098dc90bef13d.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">#!&#x2F;bin&#x2F;bash</span><br><span class="line">cd $&#123;WORKSPACE&#125;</span><br><span class="line">npm install </span><br><span class="line">npm run build:prod</span><br><span class="line">echo &quot;Version:20&quot; &gt; .&#x2F;dist&#x2F;index.html</span><br><span class="line">zip -r web.zip .&#x2F;dist&#x2F;*</span><br><span class="line">case $Status  in</span><br><span class="line">  Deploy)</span><br><span class="line">    echo &quot;Status:$Status&quot;</span><br><span class="line">    path&#x3D;&quot;&#x2F;opt&#x2F;data-detection&#x2F;bak&#x2F;$&#123;BUILD_NUMBER&#125;&quot;      #创建每次要备份的目录</span><br><span class="line">    if [ -d $path ];</span><br><span class="line">    then</span><br><span class="line">        echo &quot;The files is already  exists &quot;</span><br><span class="line">    else</span><br><span class="line">        mkdir -p  $path</span><br><span class="line">    fi</span><br><span class="line">    #APP_NAME&#x3D;group-module-1.0-SNAPSHOT.jar</span><br><span class="line">    #pid&#x3D;&#96;ps -ef|grep $APP_NAME|grep -v grep|awk &#39;&#123;print $2&#125;&#39; &#96;</span><br><span class="line">	#if [ -n &quot;$&#123;pid&#125;&quot; ]; then</span><br><span class="line">	#kill -9 $pid</span><br><span class="line">	#fi</span><br><span class="line">    \cp -f $&#123;WORKSPACE&#125;&#x2F;web.zip $path &amp;&amp; cp -f $&#123;WORKSPACE&#125;&#x2F;web.zip &#x2F;opt&#x2F;data-detection&#x2F;  #将打包好的war包备份到相应目录,覆盖已存在的目标</span><br><span class="line">    #nohup java -jar &#x2F;opt&#x2F;group-module&#x2F;group-module-1.0-SNAPSHOT.jar &gt; &#x2F;opt&#x2F;group-module&#x2F;group-module-1.0-SNAPSHOT.log 2&gt;&amp;1 &amp;      </span><br><span class="line">    echo &quot;Completing!&quot;</span><br><span class="line">    ;;</span><br><span class="line">  Rollback)</span><br><span class="line">      echo &quot;Status:$Status&quot;</span><br><span class="line">      echo &quot;Version:$Version&quot;</span><br><span class="line">      cd &#x2F;opt&#x2F;data-detection&#x2F;bak&#x2F;$Version #进入备份目录</span><br><span class="line">      #APP_NAME&#x3D;group-module-1.0-SNAPSHOT.jar</span><br><span class="line">      #pid&#x3D;&#96;ps -ef|grep $APP_NAME|grep -v grep|awk &#39;&#123;print $2&#125;&#39; &#96;</span><br><span class="line">	  #if [ -n &quot;$&#123;pid&#125;&quot; ]; then</span><br><span class="line">	  #kill -9 $pid</span><br><span class="line">	  #fi</span><br><span class="line">      \cp -f web.zip &#x2F;opt&#x2F;data-detection&#x2F; #将备份拷贝到程序打包目录中，并覆盖之前的jar包</span><br><span class="line">      #nohup java -jar &#x2F;opt&#x2F;group-module&#x2F;group-module-1.0-SNAPSHOT.jar &gt; &#x2F;opt&#x2F;group-module&#x2F;group-module-1.0-SNAPSHOT.log 2&gt;&amp;1 &amp;       </span><br><span class="line">      ;;</span><br><span class="line">  *)</span><br><span class="line">  exit</span><br><span class="line">      ;;</span><br><span class="line">esac</span><br></pre></td></tr></table></figure>
<p>文件数量控制脚本这里也需要改下路径<br><img src="https://img-blog.csdnimg.cn/c02d1dd9b8004551a547e0a44675549e.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">#!&#x2F;bin&#x2F;bash</span><br><span class="line">ReservedNum&#x3D;5  #保留文件数</span><br><span class="line">FileDir&#x3D;&#x2F;opt&#x2F;data-detection&#x2F;bak&#x2F;</span><br><span class="line">date&#x3D;$(date &quot;+%Y%m%d-%H%M%S&quot;)</span><br><span class="line"></span><br><span class="line">cd $FileDir   #进入备份目录</span><br><span class="line">FileNum&#x3D;$(ls -l | grep &#39;^d&#39; | wc -l)   #当前有几个文件夹，即几个备份</span><br><span class="line"></span><br><span class="line">while(( $FileNum &gt; $ReservedNum))</span><br><span class="line">do</span><br><span class="line">    OldFile&#x3D;$(ls -rt | head -1)         #获取最旧的那个备份文件夹</span><br><span class="line">    echo  $date &quot;Delete File:&quot;$OldFile</span><br><span class="line">    rm -rf $FileDir&#x2F;$OldFile</span><br><span class="line">    let &quot;FileNum--&quot;</span><br><span class="line">done </span><br></pre></td></tr></table></figure>
<p>最后执行部署的脚本需要重新写，前端的比较简单，写个解压跟权限的就好了<br><img src="https://img-blog.csdnimg.cn/44fd0bbee067404abf32bf1a98677150.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16"><br><img src="https://img-blog.csdnimg.cn/38b8268a7dbb4491a7b8d2ab59313ea7.png" alt="在这里插入图片描述"></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cd &#x2F;opt&#x2F;data-detection&#x2F; &amp;&amp; rm -rf dist&#x2F;*</span><br><span class="line">cd &#x2F;opt&#x2F;data-detection&#x2F; &amp;&amp; unzip web.zip &amp;&amp; rm -rf web.zip</span><br><span class="line">chmod 777 &#x2F;opt&#x2F;data-detection&#x2F;dist&#x2F;*</span><br></pre></td></tr></table></figure>
<h1 id="前端演示"><a href="#前端演示" class="headerlink" title="前端演示"></a>前端演示</h1><h2 id="deploy"><a href="#deploy" class="headerlink" title="deploy"></a>deploy</h2><p>jenkins控制台依次选择deploy,版本号23，然后点击构建</p>
<p><img src="https://img-blog.csdnimg.cn/62ce78e8cd52411c85238a97d4b0c188.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"><br>然后访问浏览器<br><img src="https://img-blog.csdnimg.cn/efee0fa146064e5a9ce7c70bb11b5cc4.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"></p>
<h2 id="Roolback"><a href="#Roolback" class="headerlink" title="Roolback"></a>Roolback</h2><p><img src="https://img-blog.csdnimg.cn/344c65e41d81449da719bb8620c7c5f9.png" alt="在这里插入图片描述"></p>
<p>jenkins控制台依次选择Rollback,版本号20，然后点击构建，成共之后访问浏览器</p>
<p><img src="https://img-blog.csdnimg.cn/8c153922bce34bf3b934360567ae9e4a.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxleENsb3duZmlzaA==,size_20,color_FFFFFF,t_70,g_se,x_16" alt="在这里插入图片描述"></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">Alex</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://blogtest.alexcld.com/posts/5876.html">http://blogtest.alexcld.com/posts/5876.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://blogtest.alexcld.com" target="_blank">Alexcld</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/jenkins%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2%E7%89%88%E6%9C%AC%E5%9B%9E%E6%BB%9A/">jenkins自动部署版本回滚</a></div><div class="post_share"><div class="social-share" data-image="https://img.alexcld.com/img/170734-15694024544d72.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/undefined.html"><img class="prev-cover" src="https://img.alexcld.com/img/catgirl.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">声明式pipeline在k8s中完成自动部署，回滚，钉钉通知</div></div></a></div><div class="next-post pull-right"><a href="/posts/9424.html"><img class="next-cover" src="https://img.alexcld.com/img/090412-15573638521155.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">win10下使用linux</div></div></a></div></nav><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://img.alexcld.com/img/author.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Alex</div><div class="author-info__description">children don't lie</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">29</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">29</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">11</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/alexclownfish"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/alexclownfish" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:ywz0207@163.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="https://vue.alexcld.com" target="_blank" title="vue站点"><i class="fab fa-vuejs"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">This is AKA Alex,respect yeah</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85java-maven%E7%8E%AF%E5%A2%83%EF%BC%8C%E6%88%91%E8%BF%99%E9%87%8C%E4%BD%BF%E7%94%A8ubuntu"><span class="toc-number">1.</span> <span class="toc-text">安装java,maven环境，我这里使用ubuntu</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85jdk"><span class="toc-number">1.1.</span> <span class="toc-text">安装jdk</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85maven"><span class="toc-number">1.2.</span> <span class="toc-text">安装maven</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85tomcat-jenkins"><span class="toc-number">2.</span> <span class="toc-text">安装tomcat,jenkins</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%88%9B%E5%BB%BAproject%E8%BF%9B%E8%A1%8C%E6%9E%84%E5%BB%BA"><span class="toc-number">3.</span> <span class="toc-text">创建project进行构建</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%AA%8C%E8%AF%81"><span class="toc-number">4.</span> <span class="toc-text">验证</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#Deploy"><span class="toc-number">4.1.</span> <span class="toc-text">Deploy</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Rollback"><span class="toc-number">4.2.</span> <span class="toc-text">Rollback</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BB%A5%E4%B8%8A%E5%86%99%E7%9A%84%E6%98%AF%E5%90%8E%E7%AB%AF%EF%BC%8C%E8%BF%99%E9%87%8C%E5%86%8D%E8%A1%A5%E5%8F%91%E4%B8%80%E4%B8%AA%E5%89%8D%E7%AB%AF%E7%9A%84"><span class="toc-number">5.</span> <span class="toc-text">以上写的是后端，这里再补发一个前端的</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85node"><span class="toc-number">5.1.</span> <span class="toc-text">安装node</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%96%B0%E5%BB%BA%E5%89%8D%E7%AB%AF%E9%A1%B9%E7%9B%AE"><span class="toc-number">5.2.</span> <span class="toc-text">新建前端项目</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%89%8D%E7%AB%AF%E6%BC%94%E7%A4%BA"><span class="toc-number">6.</span> <span class="toc-text">前端演示</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#deploy"><span class="toc-number">6.1.</span> <span class="toc-text">deploy</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Roolback"><span class="toc-number">6.2.</span> <span class="toc-text">Roolback</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/posts/5880.html" title="docker-compose部署java前后端分离项目"><img src="https://img.alexcld.com/img/003219-15968179390168.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="docker-compose部署java前后端分离项目"/></a><div class="content"><a class="title" href="/posts/5880.html" title="docker-compose部署java前后端分离项目">docker-compose部署java前后端分离项目</a><time datetime="2022-01-17T07:02:14.000Z" title="发表于 2022-01-17 15:02:14">2022-01-17</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/5877.html" title="jenkins多用户权限管理"><img src="https://img.alexcld.com/img/playpiano.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="jenkins多用户权限管理"/></a><div class="content"><a class="title" href="/posts/5877.html" title="jenkins多用户权限管理">jenkins多用户权限管理</a><time datetime="2022-01-17T06:51:58.000Z" title="发表于 2022-01-17 14:51:58">2022-01-17</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/undefined.html" title="声明式pipeline在k8s中完成自动部署，回滚，钉钉通知"><img src="https://img.alexcld.com/img/catgirl.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="声明式pipeline在k8s中完成自动部署，回滚，钉钉通知"/></a><div class="content"><a class="title" href="/posts/undefined.html" title="声明式pipeline在k8s中完成自动部署，回滚，钉钉通知">声明式pipeline在k8s中完成自动部署，回滚，钉钉通知</a><time datetime="2021-12-10T03:24:28.000Z" title="发表于 2021-12-10 11:24:28">2021-12-10</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/5876.html" title="jenkins自动部署版本回滚"><img src="https://img.alexcld.com/img/170734-15694024544d72.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="jenkins自动部署版本回滚"/></a><div class="content"><a class="title" href="/posts/5876.html" title="jenkins自动部署版本回滚">jenkins自动部署版本回滚</a><time datetime="2021-10-09T08:07:14.000Z" title="发表于 2021-10-09 16:07:14">2021-10-09</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/9424.html" title="win10下使用linux"><img src="https://img.alexcld.com/img/090412-15573638521155.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="win10下使用linux"/></a><div class="content"><a class="title" href="/posts/9424.html" title="win10下使用linux">win10下使用linux</a><time datetime="2021-10-09T08:01:06.000Z" title="发表于 2021-10-09 16:01:06">2021-10-09</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://img.alexcld.com/img/170734-15694024544d72.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By Alex</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">alexclownfish</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">简</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="chat_btn" type="button" title="rightside.chat_btn"><i class="fas fa-sms"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>function loadValine () {
  function initValine () {
    const valine = new Valine(Object.assign({
      el: '#vcomment',
      appId: 'rdtTOtMkfivtPvkQaaDXmJUd-gzGzoHsz',
      appKey: 'E68vw0GUqAynKmIiHtw9FLRA',
      placeholder: '留下你的看法吧！！',
      avatar: 'monsterid',
      meta: 'nick,mail,link'.split(','),
      pageSize: '10',
      lang: 'zh-CN',
      recordIP: true,
      serverURLs: '',
      emojiCDN: '',
      emojiMaps: "",
      enableQQ: true,
      path: window.location.pathname,
      requiredFields: ["nick,mail"],
      visitor: false
    }, null))
  }

  if (typeof Valine === 'function') initValine() 
  else getScript('https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js').then(initValine)
}

if ('Valine' === 'Valine' || !false) {
  if (false) btf.loadComment(document.getElementById('vcomment'),loadValine)
  else setTimeout(loadValine, 0)
} else {
  function loadOtherComment () {
    loadValine()
  }
}</script></div><script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script id="click-show-text" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-show-text.min.js" data-mobile="false" data-text="I,LOVE,YOU" data-fontsize="15px" data-random="false" async="async"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start -->
  <script data-pjax src="https://cdn.jsdelivr.net/gh/Zfour/hexo-github-calendar@1.21/hexo_githubcalendar.js"></script>
  <script data-pjax>
        function GithubCalendarConfig(){
            var git_githubapiurl ="https://python-github-calendar-api.vercel.app/api?alexclownfish";
            var git_color =['#ebedf0', '#fdcdec', '#fc9bd9', '#fa6ac5', '#f838b2', '#f5089f', '#c4067e', '#92055e', '#540336', '#48022f', '#30021f'];
            var git_user ="alexclownfish";
            var parent_div_git = document.getElementById('recent-posts');
            var git_div_html = '<div class="recent-post-item" style="width:100%;height:auto;padding:10px;"><div id="github_loading" style="width:10%;height:100%;margin:0 auto;display: block"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"  viewBox="0 0 50 50" style="enable-background:new 0 0 50 50" xml:space="preserve"><path fill="#d0d0d0" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z" transform="rotate(275.098 25 25)"><animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"></animateTransform></path></svg></div><div id="github_container"></div></div>';
            if(parent_div_git && location.pathname =='/'){
                console.log('已挂载github calendar')
                // parent_div_git.innerHTML=git_div_html+parent_div_git.innerHTML // 无报错，但不影响使用(支持pjax跳转)
                parent_div_git.insertAdjacentHTML("afterbegin",git_div_html) // 有报错，但不影响使用(支持pjax跳转)
            };
            GithubCalendar(git_githubapiurl,git_color,git_user)
        }
        if(document.getElementById('recent-posts')){
            GithubCalendarConfig()
        }
    </script>
    <style>#github_container{min-height:280px}@media screen and (max-width:650px) {#github_container{background-image:;min-height:0px}}</style>
    <style></style><!-- hexo injector body_end end --><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"model":{"jsonPath":"/live2dw/assets/tororo.model.json"},"display":{"position":"left","width":150,"height":300},"mobile":{"show":true},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body></html>